package 周赛;

import java.util.HashSet;

public class 检查是否每行每列都包含全部整数 {
    public boolean checkValid(int[][] matrix) {
        int n = matrix.length;
        for (int i = 0; i < n; i++) {
            HashSet<Integer> set1 = new HashSet<>();
            HashSet<Integer> set2 = new HashSet<>();
            for (int j = 0; j < n; j++) {
                set1.add(matrix[i][j]);
            }
            if (set1.size()<n)
                return false;
            for (int j = 0; j < n; j++) {
                set2.add(matrix[j][i]);
            }
            if (set2.size()<n)
                return false;
        }
        return true;
    }
}
